Page({
  data: {
    tabs: [
      { id: 0, name: "体验问题", isactive: true },
      { id: 1, name: "商品、商家投诉", isactive: false }
    ],
    imagearr: [],
    inputValue: ''
  },
  //外网图片数组
  UpLoadImgs: [],
  indexchange(e) {
    const { index } = e.detail
    let { tabs } = this.data
    tabs.forEach((v, i) => i === index ? v.isactive = true : v.isactive = false)
    this.setData({
      tabs
    })
  },
  addimage() {
    wx.chooseImage({//选择图片
      count: 9,
      sizeType: ['original', 'compressed'],
      sourceType: ['album', 'camera'],
      success: (result) => {
        console.log(result)
        this.setData({
          imagearr: [...this.data.imagearr, ...result.tempFilePaths]
        })
      },
      fail: () => { },
      complete: () => { }
    });

  },
  handleRemoveImg(e) {//点击图片删除图片
    const { index } = e.currentTarget.dataset
    let { imagearr } = this.data
    imagearr.splice(index, 1)
    this.setData({
      imagearr
    })
  },
  getValue(e) {
    const inputValue = e.detail.value
    console.log(inputValue)
    this.setData({
      inputValue: inputValue
    })
  },
  add() {//提交文字信息和
    const { inputValue, imagearr } = this.data
    if (!inputValue) {
      wx.showToast({
        title: '没请输入需要提交的文字信息',
        icon: 'none',
        mask: true
      });
      return;
    }
    if (imagearr.length != 0) {
      imagearr.forEach((v, i) => {
        wx.uploadFile({
          //图片要上传到哪里
          url: 'https://images.ac.cn/Home/Index/UploadAction/',
          //被上传的文件路径
          filePath: v,
          //上传的文件名称，后台来获取文件
          name: 'file',
          //顺带的文本信息
          formData: {},
          success: (result) => {
            console.log(result)
          }

        });
      })

    }

  }

})